package com.example.farmeri.ui.news;

import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

import com.example.farmeri.R;
import com.example.farmeri.ui.base.BaseActivity;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import butterknife.BindView;
import butterknife.ButterKnife;

public class NewscheckActivity extends BaseActivity {
    //查看消息标题
    @BindView(R.id.news_check_title)
    TextView chTitle;
    //查看消息内容
    @BindView(R.id.news_check_content)
    TextView chCont;
    //查看消息类型
    @BindView(R.id.news_check_type)
    TextView chTyp;
    //查看消息收到时间
    @BindView(R.id.news_check_time)
    TextView chTim;
    //查看消息b备注
    @BindView(R.id.news_check_remark)
    TextView chNyp;
    ////回复消息按钮
    //@BindView(R.id.newscheck_backnews)
    //Button chBac;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_newscheck);
        ButterKnife.bind(this);
        EventBus.getDefault().register(this);
        initToolBar(R.id.news_check_toolbar,"查看消息",false,true);
        //initDialog();
        setData();
    }


    private void setData() {
        Intent message = getIntent();
        chTitle.setText(message.getStringExtra("title"));
        chCont.setText(message.getStringExtra("content"));
        chTyp.setText(message.getStringExtra("messageType"));
        chTim.setText(message.getStringExtra("date"));
        chNyp.setText(message.getStringExtra("remarks"));
    }

//    public void reply(View view) {
//        Map<String,String> map = new HashMap<>();
//        map.put("id",);
//    }
//
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void stringMessage(String msg){
        if (msg.equals("success")){
            finish();
        }
        showToast(this,msg);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().unregister(this);
        }
    }
}
